/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package actions;

import Connexion.ConnexionCustomer;
import actions.facade.FacadeAction;
import com.opensymphony.xwork2.ActionContext;
import java.rmi.RemoteException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.FinderException;
import miage.beans.ClientPresentation;
import miage.sessions.ecom.remote.EcomCustomerRemote;

/**
 *
 * @author Pepito
 */
public class InfoAction extends FacadeAction {

    private static EcomCustomerRemote rechercher;
    private ClientPresentation client;
    private Map session = ActionContext.getContext().getSession();
    private String login, password;

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
    public ClientPresentation getClient() {
        return client;
    }

    public void setClient(ClientPresentation client) {
        this.client = client;
    }
    
    @Override
    public String execute(){
        rechercher = ConnexionCustomer.connectionServerBean();
        setLogin(String.valueOf(session.get("login")));
        setPassword(String.valueOf(session.get("password")));         
        System.out.println("login + password = "+login +" "+password);
        try {
            client = rechercher.getAuthentification(login, password);
        } catch (FinderException ex) {
            Logger.getLogger(AchatPanierAction.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            Logger.getLogger(AchatPanierAction.class.getName()).log(Level.SEVERE, null, ex);
        }      
        
        return "success";
    }
}
